#pragma once

#include "desktop_capturer.h"

#include "DesktopCapturerWin.h"
#include "DesktopCaptureOptions.h"
#include <thread>
#include <mutex>

class Engine :public DesktopCapturer::Callback
{
public:
	Engine();
	~Engine();
	int Init();
	int Start();
	void Wait();
	int Stop();

	void OnCaptureResult(DesktopCapturer::Result result,
		std::unique_ptr<DesktopFrame> frame) override;

	inline void setFps(int fps) {
		fps_ = fps;
	}

	inline void setMaxFrame(int64_t maxFrame) {
		maxFrame_ = maxFrame;
	}

	inline void setCb(sbeidc_cb* cb) {
		cb_ = cb;
	}
private:
	void run();
	bool running_ = false;
	std::unique_ptr<DesktopCapturerWin> dcw_;
	std::unique_ptr<std::thread> thread_;

	int fps_ = 15;
	int64_t maxFrame_ = -1;
	sbeidc_cb* cb_;
};

